cmake_minimum_required(VERSION 3.14)

project(QRemoteObjectAdvance LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core RemoteObjects Quick)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core RemoteObjects Quick)
message("--version" Qt${QT_VERSION_PATCH})

function(getQtPrivate module output)
set(QT_INCLUDE_PATH ${QT_DIR}/../../../include)
set(privatePath "${QT_INCLUDE_PATH}/Qt${module}/${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
set(${output}
${privatePath}
${privatePath}/Qt${module}
 PARENT_SCOPE)
endfunction()

getQtPrivate(Core QT_CORE_PRIVATE)

SET(ROPrivate
"./private/QROHost_Method.cpp"
"./private/QROHost_P.h"
"./private/QROHost_Property.cpp"
"./private/QROHost_Registration.cpp"
"./private/QROHost_Creation.cpp"
"./private/QROHost_Conversion.cpp"
"./private/QROHost_NetInterface.cpp"
"./private/QROHost_Hierarchy.cpp"
"./private/QROHost_P.cpp"
"./private/QROHost_Authority.cpp"
"./private/QRONode_Method.cpp"
"./private/QRONode_P.h"
"./private/QRONode_Property.cpp"
"./private/QRONode_Registration.cpp"
"./private/QRONode_Creation.cpp"
"./private/QRONode_Conversion.cpp"
"./private/QRONode_NetInterface.cpp"
"./private/QRONode_Hierarchy.cpp"
"./private/QRONode_P.cpp"
"./private/QRONode_Authority.cpp"
)

message("---QT_CORE_PRIVATE" ${QT_CORE_PRIVATE})
add_library(QRemoteObjectAdvance SHARED
  QRemoteObjectAdvance_global.h
  QRemoteObject2.cpp
  QRemoteObject2.h
  QROHost.cpp
  QROHost.h
  QRONode.h
  QRONode.cpp
  QRemoteObject2Meta_P.h
  QRemoteObject2Meta_P.cpp
  QRO_p.cpp
  QRO_p.h
  QRemoteItem.h
  QRemoteItem.cpp
  QHierarchyFactory_p.cpp
  QHierarchyFactory_p.h
  QROInterface.h
  QRemoteFunction.cpp
  QRemoteFunction.h
  QROHostDelegate.cpp
  QROHostDelegate.h
  QROClient.cpp
  QROClient.h
  ${ROPrivate}
)

target_include_directories(QRemoteObjectAdvance PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${QT_CORE_PRIVATE}
${QT_CORE_PRIVATE}/QtCore
)

set(repFiles RemoteInterface.rep)

 qt6_add_repc_sources(QRemoteObjectAdvance
     ${repFiles}
 )

 qt6_add_repc_replicas(QRemoteObjectAdvance
     ${repFiles}
 )


target_link_libraries(QRemoteObjectAdvance PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::RemoteObjects Qt${QT_VERSION_MAJOR}::Quick)

target_compile_definitions(QRemoteObjectAdvance PRIVATE QREMOTEOBJECTADVANCE_LIBRARY)
